<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.6 -->
  <link rel="stylesheet" href="/static/adminlte/bootstrap/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="/static/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" type="text/css" href="/static/css/ionicons.min.css" />
  <!-- Theme style -->
  <link rel="stylesheet" href="/static/adminlte/dist/css/AdminLTE.min.css">
		<title></title>
	</head>
	<body>

<section class="content">
      <div class="row">
		<div class="col-xs-12">
		          <div class="nav-tabs-custom">
		            <ul class="nav nav-tabs">
		              <li class="active"><a href="{{ route('admin.spec.index') }}">规格列表</a></li>
		              <li><a href="{{ route('admin.spec.add') }}">添加规格</a></li>
		            </ul>
	

					</div>
		            <div class="tab-content">
	
						<div class="row">
						    <div class="col-md-12">


								<div class="navbar navbar-default">
					              <form class="navbar-form form-inline" action="{{ route('admin.spec.index') }}" method="get">
					                <div class="form-group">
					                  	<select name="type_id" class="form-control">
					                    	<option value="">所有分类</option>
					                    	@foreach($goodstype as $v)        
					                    	<option value="{{ $v['id'] }}" {{ $v['id']==request('type_id') ? 'selected="selected"' : '' }}>{{ $v['name'] }}</option>
					                    	@endforeach
					                   	</select>
					                </div>                  
					                <div class="form-group">                 
						                <button type="submit" class="btn btn-primary pull-right">
						                 <i class="fa fa-search"></i> 筛选
						                </button>
					                </div>
					          	</div>
							
									
									
						   </div><!--/.col -->
						    
						    <div class="col-md-12">
				                <table class="table table-hover">
				                    <thead>
				                    <tr>
				                        <th style="width: 30px;">ID</th>
				                        <th>商品类型</th>
				                        <th>规格名称</th>
				                        <th>规格项</th>
				                        <th>排序</th>
				                        <th>操作</th>
				                    </tr>
				                    </thead>
				                    <tbody>
				                    @foreach ($list as $vo)
				                    <tr>
				                        <td>{{$vo['id']}}</td>
				                        <td>{{$vo['type_name']}}</td>
				                        <td>{{$vo['name']}}</td>
				                        <td>{{ $vo['items'] }}</td>
				                        <td>
				                        	<input style="width: 50px;" type="text" onchange="sortup({{$vo['id']}},{{$vo['sort']}},this)" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" value="{{$vo['sort']}}" />
				                        </td>
				                        <td>
				                            <a href="{{ route('admin.spec.edit',['id'=>$vo['id']]) }}" class="label label-success">编辑</a>
				                            <a href="{{ route('admin.spec.del',['id'=>$vo['id']]) }}" class="label label-danger ajax-delete">删除</a>
				                        </td>
				                    </tr>
				                    @endforeach
				                    </tbody>
				                </table> 
						    </div><!--/.col -->						    
						</div>	<!--/.row -->	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

		            </div><!-- /.tab-content -->
		          </div><!-- /.nav-tabs-custom -->
		</div><!--/.row-->
      </div>
  </section>
<!-- jQuery 2.2.3 -->
<script src="/static/adminlte/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="/static/layer/layer.js" type="text/javascript" charset="utf-8"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/static/adminlte/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/js/admin.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

	//更新排序
	function sortup(idx,sort,obj){
		var _value = $(obj).val();
		$.ajax({
			type:"get",
			data:{
				id:idx,
				sort:_value
			},
			url:"{{ route('admin.spec.sortup') }}",
			success:function(info){
                layer.msg(info.msg,{ico:1,time:2000})
                if(info.code=='10001'){
                	$(obj).val(sort);//如果排序失败回复原值
                }
			}
		});
	}

</script>
	</body>
</html>
